package com.sgb.zhaocai.view.demand.fragment;

import android.annotation.SuppressLint;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.google.android.material.tabs.TabLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;
import com.scwang.smart.refresh.layout.listener.ScrollBoundaryDecider;
import com.sgb.zhaocai.R;
import com.sgb.zhaocai.databinding.FragmentDemandForecastListBinding;
import com.sgb.zhaocai.entity.DemandForecastListBean;
import com.sgb.zhaocai.entity.DemandForecastListEntity;
import com.sgb.zhaocai.utils.PickCopyUtils;
import com.sgb.zhaocai.view.demand.adapter.DemandListAdapter;
import com.sgb.zhaocai.widget.threefliter.ZCThreeLevelFilterWindow;
import com.sgb.zhaocai.viewmodel.DemandForecastListModel;
import com.swgk.core.base.AppLazyFragment;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.util.SharedPreferenceUtil;
import com.swgk.core.view.areapopup.AddressEntity;
import com.swgk.core.view.areapopup.GoodsSourceLocationEntity;
import com.swgk.core.view.areapopup.ThreeLevelAreaWindow;
import com.swgk.core.view.selection.CommonPopEntity;
import com.swgk.core.view.selection.MemberStatusView;

import java.util.List;

/**
 * Time:2021/8/13
 * AUTHOR:F_Q
 * Description:招标大厅-需求预告
 */
public class DemandForecastListFragment extends AppLazyFragment implements MemberStatusView.OnChooseListener {
    public static final String FROM_WHERE = "FROM_WHERE";
    private FragmentDemandForecastListBinding binding;
    private String[] mTitles = {"材料采购", "机械租赁","设备租赁", "劳务用工", "分包计划"};
    private DemandForecastListModel mModel;
    private boolean isLoadMore = false;
    private DemandForecastListBean requestBean;
    private String longitude = "";
    private String latitude = "";
    //地址选择
    private ThreeLevelAreaWindow mAddressPop;
    private String province = "";
    private String city = "";
    private int position = 0;
    //地址选择list
    private List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>> scrData;
    //排序
    private String sort = "";
    //工程类型
    private String projectType = "";
    //时间
    private String startTime = "";
    private DemandListAdapter demandlistadapter;
    private boolean isEnableLoadMore = false; //是否可以上拉加载
    private String mNo1 = "";
    private String mNo2 = "";
    private String mNo3 = "";
    private List<CommonPopEntity> commonlist;
    private String typeName1 = "";
    private ZCThreeLevelFilterWindow popCategory;
    private String searchName = "";

    public static DemandForecastListFragment newInstance(String type) {
        DemandForecastListFragment fragment = new DemandForecastListFragment();
        Bundle bundle = new Bundle();
        bundle.putString(FROM_WHERE, type);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_demand_forecast_list, container, false);
        mModel = new ViewModelProvider(this).get(DemandForecastListModel.class);
        return binding.getRoot();
    }

    @Override
    protected void initView() {
        super.initView();
        longitude = SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.LONGITUDE_ID, "");
        latitude = SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.LATITUDE_ID, "");
        if (TextUtils.isEmpty(longitude)) {
            longitude = "0";
        }
        if (TextUtils.isEmpty(latitude)) {
            longitude = "0";
        }
        if (demandlistadapter == null) {
            demandlistadapter = new DemandListAdapter(getActivity(), null);
        }
        LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
        binding.recyclerView.setLayoutManager(layoutManager);
        binding.recyclerView.setAdapter(demandlistadapter);
        demandlistadapter.setOnItemClick(new AdapterOnItemClick<DemandForecastListEntity>() {
            @Override
            public void onItemClick(DemandForecastListEntity demandForecastListEntity, int position) {
                mModel.getWebH5(DemandForecastListFragment.this, demandForecastListEntity.getId(), demandForecastListEntity.getModuleType());
            }
        });
        demandlistadapter.setOnItemStateOperate(new DemandListAdapter.OnItemStateOperate() {
            @Override
            public void OnItem(DemandForecastListEntity entity) {
                mModel.getWebH5(DemandForecastListFragment.this, entity.getId(), entity.getModuleType());
            }
        });
        binding.swipeRefresh.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                isLoadMore = true;
                requestBean.page++;
                //上拉加载更多
                mModel.getMaterialHomeList(DemandForecastListFragment.this, position, requestBean);
            }

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                initDataList();
                binding.swipeRefresh.finishRefresh(300);
            }
        });
        //解决 在实现 上拉加载更多 和 下拉刷新 时  遇到item不在顶端就执行了刷新的方法和数据item没有填满屏幕也执行了加载更多
        binding.swipeRefresh.setScrollBoundaryDecider(new ScrollBoundaryDecider() {
            @SuppressLint("RestrictedApi")
            @Override
            public boolean canRefresh(View content) {
                if (binding.scrollview == null) return false;
                if (binding.scrollview.computeVerticalScrollOffset() == 0)
                    return true;
                return false;
            }

            @Override
            public boolean canLoadMore(View content) {
                if (binding.scrollview == null) return false;
                //获取recyclerView的高度
                binding.scrollview.getHeight();
                //整个View控件的高度
                @SuppressLint("RestrictedApi") int scrollRange = binding.scrollview.computeVerticalScrollRange();
                //当前屏幕之前滑过的距离
                @SuppressLint("RestrictedApi") int scrollOffset = binding.scrollview.computeVerticalScrollOffset();
                //当前屏幕显示的区域高度
                @SuppressLint("RestrictedApi") int scrollExtent = binding.scrollview.computeVerticalScrollExtent();
                int height = binding.scrollview.getHeight();
                if (height > scrollRange) {
                    return false;
                }
                if (isEnableLoadMore && scrollRange <= scrollOffset + scrollExtent) {
                    return true;
                }
                return false;
            }
        });
        initviewData();

    }

    private void initviewData() {
        binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                binding.startTime.refreshChoose("", binding.startTime.getKeyName(), 0);
                binding.sort.refreshChoose("", binding.sort.getKeyName(), 0);
                binding.projectType.refreshChoose("", binding.projectType.getKeyName(), 0);
                binding.district.refreshChoose("", binding.district.getKeyName(), 0);
                city = "";
                province = "";
                if (scrData != null) {
                    String ProvinceCode = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.AREA_CODE, "");
                    if (!TextUtils.isEmpty(ProvinceCode)) {
                        mAddressPop.setData(scrData, true, ProvinceCode);
                    } else {
                        mAddressPop.setData(scrData, true);
                    }
                }
                binding.startTime.clearData();
                binding.sort.clearData();
                binding.projectType.clearData();
                requestBean = new DemandForecastListBean();
                position = tab.getPosition();
                mNo1 = "";
                mNo2 = "";
                mNo3 = "";
                requestBean.setCategoryId("");
                switch (position) {
                    case 0://材料
                        mModel.getMaterialType(DemandForecastListFragment.this);
                        break;
                    case 1://机械
                        mModel.getMechanicalType(DemandForecastListFragment.this);
                        break;
                    case 2://设备
                        mModel.getEquipmentType(DemandForecastListFragment.this);
                        break;
                }
                //更新view信息
                listData(position);
                //列表数据
                initDataList();
                if (tab != null && tab.getCustomView() != null) {
                    TextView tabSelect = tab.getCustomView().findViewById(R.id.tv_tab_item);
                    ImageView imageView = tab.getCustomView().findViewById(R.id.image_tab_item);
                    PickCopyUtils.setDemandForecastIv(tab.getPosition(), imageView, true, getContext());
                    tabSelect.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
                    tabSelect.setTextColor(getResources().getColor(R.color.color_main));
                    tabSelect.invalidate();
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
                if (tab != null && tab.getCustomView() != null) {
                    TextView tabSelect = tab.getCustomView().findViewById(R.id.tv_tab_item);
                    ImageView imageView = tab.getCustomView().findViewById(R.id.image_tab_item);
                    PickCopyUtils.setDemandForecastIv(tab.getPosition(), imageView, false, getContext());
                    tabSelect.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
                    tabSelect.setTextColor(getResources().getColor(R.color.color_tab_one));
                    tabSelect.invalidate();
                }
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
        //初始化popview
        initializePopView();
    }

    private void initializePopView() {
        //地区
        initAddressPopup();
        //综合排序
        binding.sort.initPopup(binding.grayLayout, binding.popLine, this);
        //工程类型
        binding.projectType.initPopup(binding.grayLayout, binding.popLine, this);
        //发布时间
        binding.startTime.initPopup(binding.grayLayout, binding.popLine, this);
        //类型
        binding.type.initPopup(binding.grayLayout, binding.popLine, this);
        //类型处理
        initCateGoryPopup();
        binding.type.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showCategoryPop();
            }
        });
    }

    private void initCateGoryPopup() {
        popCategory = new ZCThreeLevelFilterWindow(getContext());
        popCategory.setBgView(binding.grayLayout);
        popCategory.setOnResultClick(new ZCThreeLevelFilterWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                CommonPopEntity pickResultProject1 = (CommonPopEntity) key1;
                CommonPopEntity pickResultProject2 = (CommonPopEntity) key2;
                CommonPopEntity pickResultProject3 = (CommonPopEntity) key3;
                switch (position) {
                    case 0://材料
                        if (pickResultProject1!=null&&!TextUtils.isEmpty(pickResultProject1.getTypeName())){
                            if (!pickResultProject1.getTypeName().equals("全部")) {
                                typeName1 = pickResultProject1.getTypeName();
                                mNo1 = pickResultProject1.getId();
                                requestBean.setCategoryId(mNo1);
                            }else {
                                typeName1 = "";
                                mNo1 = "";
                                mNo2 = "";
                                mNo3 = "";
                                requestBean.setCategoryId("");
                                popCategory.setData(commonlist, 0);
                            }
                        }
                        if (pickResultProject2!=null&&!TextUtils.isEmpty(pickResultProject2.getTypeName())){
                            if (!pickResultProject2.getTypeName().equals("全部")){
                                typeName1 = pickResultProject2.getTypeName();
                                mNo2 = pickResultProject2.getId();
                                requestBean.setCategoryId(mNo2);
                            }
                        }
                        if (pickResultProject3!=null&&!TextUtils.isEmpty(pickResultProject3.getTypeName())){
                            if (!pickResultProject3.getTypeName().equals("全部")){
                                typeName1 = pickResultProject3.getTypeName();
                                mNo3 = pickResultProject3.getId();
                                requestBean.setCategoryId(mNo3);
                            }
                        }
                        binding.type.updateChooseTextStatus(1, TextUtils.isEmpty(typeName1)? binding.type.getKeyName():typeName1);
                        break;
                    case 1://机械
                    case 2://设备
                        if (pickResultProject3!=null&&!TextUtils.isEmpty(pickResultProject1.getTypeName())){
                            if (!pickResultProject1.getTypeName().equals("全部")) {
                                typeName1 = pickResultProject1.getTypeName();
                                mNo1 = pickResultProject1.getNo();
                                requestBean.setCategoryId(mNo1);
                            }else {
                                typeName1 = "";
                                mNo1 = "";
                                mNo2 = "";
                                mNo3 = "";
                                requestBean.setCategoryId("");
                                popCategory.setData(commonlist, 0);
                            }
                        }
                        if (pickResultProject3!=null&&!TextUtils.isEmpty(pickResultProject2.getTypeName())){
                            if (!pickResultProject2.getTypeName().equals("全部")) {
                                typeName1 = pickResultProject2.getTypeName();
                                mNo2 = pickResultProject2.getNo();
                                requestBean.setCategoryId(mNo2);
                            }
                        }
                        binding.type.updateChooseTextStatus(1, TextUtils.isEmpty(typeName1)? binding.type.getKeyName():typeName1);
                        break;
                }
                //刷新数据
                initDataList();
            }

            @Override
            public void reset() {
                mNo1 = "";
                mNo2 = "";
                mNo3 = "";
                requestBean.setCategoryId("");
                popCategory.setData(commonlist, 0);
                binding.type.updateChooseTextStatus(0, binding.type.getKeyName());
                //刷新数据
                initDataList();
            }
        });
        popCategory.setOnDismissListener(() -> {
            if (position == 0){
                if(!TextUtils.isEmpty(mNo1) || !TextUtils.isEmpty(mNo2) || !TextUtils.isEmpty(mNo3)){
                    binding.type.updateChooseTextStatus(1, null);
                }else {
                    binding.type.updateChooseTextStatus(0, binding.type.getKeyName());
                }
            }else {
                if (!TextUtils.isEmpty(mNo1) || !TextUtils.isEmpty(mNo2)) {
                    binding.type.updateChooseTextStatus(1, null);
                } else {
                    binding.type.updateChooseTextStatus(0, binding.type.getKeyName());
                }
            }
        });
    }

    //地区
    private void initAddressPopup() {
        binding.district.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (scrData == null || scrData.size() == 0) {
                    mModel.getAddressModel(DemandForecastListFragment.this);
                    return;
                }
                binding.popLine.setVisibility(View.VISIBLE);
                if (!TextUtils.isEmpty(province) || !TextUtils.isEmpty(city)) {
                    binding.district.updateChooseTextStatus(-2, null);
                } else {
                    binding.district.updateChooseTextStatus(-1, binding.district.getKeyName());
                }
                mAddressPop.showPopwindow0(binding.popLine);
            }
        });
        mAddressPop = new ThreeLevelAreaWindow(getActivity());
        mAddressPop.setBgView(binding.grayLayout);
        mAddressPop.setMemberHeight();
        mAddressPop.setCitySingle();
        mAddressPop.setProvinceSingle();
        mAddressPop.setShowSimpleName(true);
        mAddressPop.setOnlyShowProAndCity(true);
        mAddressPop.setAllSingleSelect(true);
        mAddressPop.setThreeListIsGone(true);
        mAddressPop.setOnResultClick(new ThreeLevelAreaWindow.OnResultClickProxy() {
            @Override
            protected void result(GoodsSourceLocationEntity entity) {
                province = "";
                city = "";
                requestBean.setProvince(province);
                requestBean.setCity(city);
                binding.district.updateChooseTextStatus(0, binding.district.getKeyName());
                if (!TextUtils.isEmpty(entity.getProvinceNo())) {
                    province = entity.getProvinceNo();
                    requestBean.setProvince(province);
                    binding.district.updateChooseTextStatus(1, entity.getProvinceName());
                    if (!TextUtils.isEmpty(entity.getCityNo())) {
                        city = entity.getCityNo();
                        requestBean.setCity(city);
                        binding.district.updateChooseTextStatus(1, entity.getCityName());
                    }
                }
                //刷新数据
                initDataList();
            }
        });
        mAddressPop.setOnDismissListener(() -> {
            if (!TextUtils.isEmpty(province) || !TextUtils.isEmpty(city)) {
                binding.district.updateChooseTextStatus(1, null);
            } else {
                binding.district.updateChooseTextStatus(0, binding.district.getKeyName());
            }
        });
    }

    //列表数据
    private void initDataList() {
        if (requestBean == null) {
            requestBean = new DemandForecastListBean();
        }
        requestBean.setAddrDetailLat(latitude + "");
        requestBean.setAddrDetailLng(longitude + "");
        if (!TextUtils.isEmpty(searchName)){
            requestBean.setKeyword(searchName);
        }else {
            requestBean.setKeyword("");
        }
        isLoadMore = false;
        requestBean.page = 1;
        mModel.getMaterialHomeList(DemandForecastListFragment.this, position, requestBean);
    }

    //布局处理
    private void listData(int position) {
        //sort、project_type、start_time、district
        switch (position) {
            case 0:
            case 1:
            case 2:
                binding.type.setVisibility(View.VISIBLE);
                binding.projectType.setVisibility(View.GONE);
                break;
            case 3:
            case 4:
                binding.type.setVisibility(View.GONE);
                binding.projectType.setVisibility(View.VISIBLE);
                break;
        }
    }


    @Override
    protected void onLazyLoad() {
        //菜单处理
        mTitlesData();
        //列表新消息
        listData(0);
        //数据信息
        initDataList();
        //获取经纬度
        getLatitudeLongitudeData();
    }

    //初始化数据
    private void getLatitudeLongitudeData() {
        mModel.getSortType(this);
        mModel.getProjectTypeList(this);
        mModel.getTime(this);
        mModel.getMaterialType(DemandForecastListFragment.this);
    }

    private void mTitlesData() {
        for (int i = 0; i < mTitles.length; i++) {
            binding.tabLayout.addTab(binding.tabLayout.newTab());
            binding.tabLayout.getTabAt(i).setCustomView(R.layout.tab_item_text_image_view);
            View view = binding.tabLayout.getTabAt(i).getCustomView();
            TextView tv = view.findViewById(R.id.tv_tab_item);
            ImageView imageView = view.findViewById(R.id.image_tab_item);
            if (i == 0) {
                PickCopyUtils.setDemandForecastIv(0, imageView, true, getContext());
                tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
                tv.setTextColor(getResources().getColor(R.color.color_main));
                tv.invalidate();
            } else {
                PickCopyUtils.setDemandForecastIv(i, imageView, false, getContext());
                tv.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
                tv.setTextColor(getResources().getColor(R.color.color_tab_one));
                tv.invalidate();
            }
            tv.setText(mTitles[i]);
        }
        binding.tabLayout.getTabAt(0).select();
    }

    /**
     * 地址列表信息
     *
     * @param data
     */
    public void setAddressList(List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>> data) {
        if (data != null && data.size() > 0) {
            scrData = data;
            String ProvinceCode = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.AREA_CODE, "");
            if (!TextUtils.isEmpty(ProvinceCode)) {
                mAddressPop.setData(data, true, ProvinceCode);
            } else {
                mAddressPop.setData(data, true);
            }
            binding.popLine.setVisibility(View.VISIBLE);
            if (!TextUtils.isEmpty(province) || !TextUtils.isEmpty(city)) {
                binding.district.updateChooseTextStatus(-2, null);
            } else {
                binding.district.updateChooseTextStatus(-1, binding.district.getKeyName());
            }
            mAddressPop.showPopwindow0(binding.popLine);
        }
    }

    //pop初始化数据
    @Override
    public void onLoadChooseData(String mKeyName) {
        switch (mKeyName) {
            case "综合排序":
                mModel.getSortType(this);
                break;
            case "工程类型":
                mModel.getProjectTypeList(this);
                break;
            case "发布时间":
                mModel.getTime(this);
                break;
        }
    }

    //pop点击事件
    @Override
    public void onChooseResult(String mKeyName, CommonPopEntity entity, Object... objects) {
        int position = (int) objects[0];
        String no = position == 0 ? "" : entity.getNo();
        String id = position == 0 ? "" : entity.getId();
        String name = position == 0 ? "" : entity.getTypeName();
        switch (mKeyName) {
            case "综合排序":
                if (!TextUtils.equals(no, sort)) {
                    sort = no;
                    requestBean.setSortMethod(sort);
                }
                break;
            case "工程类型":
                if (!TextUtils.equals(name, projectType)) {
                    projectType = name;
                    requestBean.setEngineeringType(projectType);
                }
                break;
            case "发布时间":
                if (!TextUtils.equals(no, startTime)) {
                    startTime = no;
                    requestBean.setPlanUseTime(startTime);
                }
                break;
        }
        //刷新数据
        initDataList();
    }

    /**
     * 综合排序
     *
     * @param datas
     */
    public void setSortTypeList(List<CommonPopEntity> datas) {
        setChooseItemData(1, datas);
    }

    /**
     * 工程类型
     *
     * @param data
     */
    public void setProjectTypeList(List<CommonPopEntity> data) {
        setChooseItemData(2, data);
    }

    /**
     * 时间
     *
     * @param data
     */
    public void setTime(List<CommonPopEntity> data) {
        setChooseItemData(3, data);
    }

    //弹窗信息
    public void setChooseItemData(int type, List<CommonPopEntity> data) {
        if (data == null || data.size() == 0) return;
        switch (type) {
            case 1://排序方式
                binding.sort.setData(data, sort);
                break;
            case 2://工程类别
                binding.projectType.setData(data, projectType);
                break;
            case 3://发布时间
                binding.startTime.setData(data, startTime);
                break;
        }
    }


    /**
     * 列表返回数据
     *
     * @param data
     */
    public void setDemandList(List<DemandForecastListEntity> data) {
        binding.swipeRefresh.finishLoadMore(true);
        if (!TextUtils.isEmpty(searchName) && !isLoadMore) {
            binding.scrollview.smoothScrollTo(0, 0);
            binding.scrollview.scrollTo(0, 0);
        }
        if (data != null) {
            isEnableLoadMore = data.size() >= 10;
        }
        if (isLoadMore) {
            if (data != null && data.size() > 0) {
                demandlistadapter.addDatas(data);
            }
        } else {
            if (data != null && data.size() > 0) {
                binding.emptyView.setVisibility(View.GONE);
                binding.recyclerView.setVisibility(View.VISIBLE);
                demandlistadapter.setDatas(data);
                binding.recyclerView.scrollToPosition(0);
            } else {
                demandlistadapter.clearDatas();
                binding.emptyView.setVisibility(View.VISIBLE);
                binding.recyclerView.setVisibility(View.GONE);
            }
        }
    }

    //类型-商品类型
    public void setMaterialType(List<CommonPopEntity> data) {
        this.commonlist = data;
        popCategory.setShowThreeRecycler(true);
        popCategory.setData(data, 0);
        requestBean.setCategoryId("");
        binding.type.updateChooseTextStatus(0, binding.type.getKeyName());
    }

    //类型-机械类型
    public void setMechanicalType(List<CommonPopEntity> data) {
        this.commonlist = data;
        popCategory.setShowThreeRecycler(false);
        popCategory.setData(data, 0);
        requestBean.setCategoryId("");
        binding.type.updateChooseTextStatus(0, binding.type.getKeyName());
    }

    //类型-设备类型
    public void setEquipmentType(List<CommonPopEntity> data) {
        this.commonlist = data;
        popCategory.setShowThreeRecycler(false);
        popCategory.setData(data, 0);
        requestBean.setCategoryId("");
        binding.type.updateChooseTextStatus(0, binding.type.getKeyName());
    }

    //显示类型弹窗
    public void showCategoryPop() {
        binding.popLine.setVisibility(View.VISIBLE);
        if (!TextUtils.isEmpty(mNo1)) {
            binding.type.updateChooseTextStatus(-2, null);
        } else {
            binding.type.updateChooseTextStatus(-1, binding.type.getKeyName());
        }
        popCategory.showPopwindow0(binding.popLine);
    }

    public void updateData(String Name) {
        searchName = Name;
        initDataList();
    }
}
